﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;

namespace HOTEL_MANAGEMENT
{
    public partial class frmTiepTan : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        private int plag = 0;
        public void GoiForm(Form frm)
        {
            frm.MdiParent = this;
            frm.Dock = DockStyle.Fill;
            frm.Activate();
            frm.WindowState = FormWindowState.Normal;
            frm.Show();
        }
        public void GoiFormDangNhap(Form frm)
        {
            frm.Dock = DockStyle.Fill;
            //frm.Activate();
            frm.WindowState = FormWindowState.Normal;
            frm.Show();
        }
         public frmTiepTan()
        {
            InitializeComponent();
        }

        private void frmTiepTan_Load(object sender, EventArgs e)
        {
            plag = 1;
            GoiForm(STT_TraCuuPhong.getInstance().Layfrm());
            //frmTiepTan frm = new frmTiepTan();            
            lbtenNguoiDung.Text = "Nhân viên : " + SM_DangNhap.getInstance().TenNguoiDung;
            plag = 0;
        }

        private void rbTiepTan_SelectedPageChanging(object sender, DevExpress.XtraBars.Ribbon.RibbonPageChangingEventArgs e)
        {
            if (e.Page.KeyTip == "PHONG")
            {
                GoiForm(STT_TraCuuPhong.getInstance().Layfrm());
            }
            else if (e.Page.KeyTip == "PHIEUTHUE")
            {
                GoiForm(STT_LapPhieuThue.getInstance().Layfrm());
            }
            else if (e.Page.KeyTip == "HOADON")
            {
                GoiForm(STT_LapHoaDon.getInstance().Layfrm());
            }
            else if (e.Page.KeyTip == "KHACHTHUE")
            {
                GoiForm(STT_TimKhachThue.getInstance().Layfrm());
            }
            else if (e.Page.KeyTip == "THONGTINCANHAN")
            {
                GoiForm(STT_ThongTinCaNhan.getInstance().Layfrm());
            }
        }

        private void btnLapPhieuThue_ItemClick(object sender, ItemClickEventArgs e)
        {
            GoiForm(STT_LapPhieuThue.getInstance().Layfrm());
        }

        private void frmTiepTan_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult result = MessageBox.Show("Bạn có muốn thoát chương trình  hay không", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (result == DialogResult.Yes)
            {
                e.Cancel = false;
                STT_LapHoaDon.Xoa();
                STT_LapPhieuThue.Xoa();
                STT_ThongKeHoaDon.Xoa();
              //  STT_TiepTan.Xoa();
                STT_ThongTinCaNhan.Xoa();
                STT_TimHoaDon.Xoa();
                STT_TimKhachThue.Xoa();
                STT_TimPhieuThue.Xoa();
                STT_TraCuuPhong.Xoa();
                SM_DangNhap.getInstance().Layfrm().Visible = true;
                SM_LoadMain.getInstance().Layfrm().Visible = true;
            }
            else
            {
                e.Cancel = true;
            }
        }

        private void btntatCaPhong_ItemClick(object sender, ItemClickEventArgs e)
        {
            STT_TraCuuPhong.getInstance().Layfrm().Hide();
            STT_TraCuuPhong.getInstance().NghiepVu = "TatCa";
            GoiForm(STT_TraCuuPhong.getInstance().Layfrm());
        }

        private void btnphongTrong_ItemClick(object sender, ItemClickEventArgs e)
        {
            STT_TraCuuPhong.getInstance().Layfrm().Hide();
            STT_TraCuuPhong.getInstance().NghiepVu = "Trong";
            GoiForm(STT_TraCuuPhong.getInstance().Layfrm());
        }
        private void btnphongDangThue_ItemClick(object sender, ItemClickEventArgs e)
        {
            STT_TraCuuPhong.getInstance().Layfrm().Hide();
            STT_TraCuuPhong.getInstance().NghiepVu = "DangThue";
            GoiForm(STT_TraCuuPhong.getInstance().Layfrm());

        }
        private void lbThoat_Click(object sender, EventArgs e)
        {
            if (SM_DangNhap.getInstance().LuuPass == false)
            {
                SM_DangNhap.getInstance().XoaTatCaThongTin();
            }
            SM_DangNhap.getInstance().DangNhapThanhCong = false;
            
            this.Close();            
        }

        private void btntatCaPhieuThue_ItemClick(object sender, ItemClickEventArgs e)
        {
            STT_TimPhieuThue.getInstance().Layfrm().Hide();
            STT_TimPhieuThue.getInstance().NghiepVu = "TatCa";
            GoiForm(STT_TimPhieuThue.getInstance().Layfrm());            
        }

        private void btnphieuThueHienTai_ItemClick(object sender, ItemClickEventArgs e)
        {
            STT_TimPhieuThue.getInstance().Layfrm().Hide();
            STT_TimPhieuThue.getInstance().NghiepVu = "ChuaThanhToan";
            GoiForm(STT_TimPhieuThue.getInstance().Layfrm());
        }

        private void btnphieuThueDaThanhToan_ItemClick(object sender, ItemClickEventArgs e)
        {
            STT_TimPhieuThue.getInstance().Layfrm().Hide();
            STT_TimPhieuThue.getInstance().NghiepVu = "DaThanhToan";
            GoiForm(STT_TimPhieuThue.getInstance().Layfrm());
          
        }

        private void xtraTabbedMdiManager1_SelectedPageChanged(object sender, EventArgs e)
        {
            if (xtraTabbedMdiManager1.SelectedPage != null)
            {
                if (xtraTabbedMdiManager1.SelectedPage.Text == "Tra Cứu Phòng")
                    rbTiepTan.SelectedPage = rbpphong;
                if (xtraTabbedMdiManager1.SelectedPage.Text == "Lập phiếu thuê" || xtraTabbedMdiManager1.SelectedPage.Text == "Tìm phiếu thuê")
                    rbTiepTan.SelectedPage = rbpphieuThue;
                if (xtraTabbedMdiManager1.SelectedPage.Text == "Lập Hóa Đơn" || xtraTabbedMdiManager1.SelectedPage.Text == "Thống Kê Hóa Đơn" || xtraTabbedMdiManager1.SelectedPage.Text == "Tìm hóa đơn")
                    rbTiepTan.SelectedPage = rbphoaDon;
                if (xtraTabbedMdiManager1.SelectedPage.Text == "TÌM KHÁCH THUÊ")
                    rbTiepTan.SelectedPage = rbpkhachThue;
                if (xtraTabbedMdiManager1.SelectedPage.Text == "Thông Tin Cá Nhân")
                    rbTiepTan.SelectedPage = rbpthongTinCaNhan;
            }           
        }
        private void btnthongKe_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void btntimHoaDon_ItemClick(object sender, ItemClickEventArgs e)
        {
            GoiForm(STT_TimHoaDon.getInstance().Layfrm());
        }

        private void btntatCaKhachThue_ItemClick(object sender, ItemClickEventArgs e)
        {
            STT_TimKhachThue.getInstance().Layfrm().Hide();
            STT_TimKhachThue.getInstance().NghiepVu = "TatCa";
            GoiForm(STT_TimKhachThue.getInstance().Layfrm());
        }

        private void btnkhachTrongNuoc_ItemClick(object sender, ItemClickEventArgs e)
        {

            STT_TimKhachThue.getInstance().Layfrm().Hide();
            STT_TimKhachThue.getInstance().NghiepVu = "TrongNuoc";
            GoiForm(STT_TimKhachThue.getInstance().Layfrm());
        }

        private void btnkhachNuocNgoai_ItemClick(object sender, ItemClickEventArgs e)
        {

            STT_TimKhachThue.getInstance().Layfrm().Hide();
            STT_TimKhachThue.getInstance().NghiepVu = "NuocNgoai";
            GoiForm(STT_TimKhachThue.getInstance().Layfrm());
        }

        private void lbDangXuat_Click(object sender, EventArgs e)
        {
            if (SM_DangNhap.getInstance().LuuPass == false)
            {
                SM_DangNhap.getInstance().XoaTatCaThongTin();
            }
            SM_DangNhap.getInstance().DangNhapThanhCong = false;

            this.Close();
        }


        private void btnlapHoaDon_ItemClick(object sender, ItemClickEventArgs e)
        {
            GoiForm(STT_LapHoaDon.getInstance().Layfrm());
        }
   }
}